<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .red{
        color: red;
    }
    .green{
        color: green;
    }
  </style>
</head>
<body>
<div id="app">
<!--  使用对象语法，动态改变标签的class属性-->
  <h2 :class="{red: flag,green: flag2}">{{ msg }}</h2>
  <br>
  <button @click="handlerChange">改变颜色</button>
</div>
<script src="../node_modules/vue/dist/vue.js"></script>
<script>
  new Vue({
    el: "#app",
    data: {
      msg: "hello,world",
      flag:true,
      flag2:false
    },
    methods:{
      handlerChange(){
        this.flag=!this.flag
        this.flag2=!this.flag2
      }
    }
  })
</script>
</body>
</html>